import axios from 'axios'
import { ElMessage } from 'element-plus'
const service = axios.create({
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 100000
})
service.interceptors.request.use(
    config => {
       // console.log('request intercepted')
        return config
    },
    err => {
        return Promise.reject(err)
    }
)
service.interceptors.response.use(
    response => {
        const res = response.data
        if(res.code != 20000){
            console.log('')
        }
        return response
    },
    err => {
        ElMessage({
            message: err.message || 'Error',
            type: 'error',
            duration: 5 * 1000
          })
        return Promise.reject(err)
    }
)
export default service